<!doctype html>
<html lang="en">
<head>
    <title>Code coverage report for javascripts/explorev2/components/ExploreViewContainer.jsx</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="../../../prettify.css" />
    <link rel="stylesheet" href="../../../base.css" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style type='text/css'>
        .coverage-summary .sorter {
            background-image: url(../../../sort-arrow-sprite.png);
        }
    </style>
</head>
<body>
<div class='wrapper'>
  <div class='pad1'>
    <h1>
      <a href="../../../index.html">All files</a> / <a href="index.html">javascripts/explorev2/components</a> ExploreViewContainer.jsx
    </h1>
    <div class='clearfix'>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Statements</span>
        <span class='fraction'>0/58</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Branches</span>
        <span class='fraction'>0/24</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Functions</span>
        <span class='fraction'>0/5</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Lines</span>
        <span class='fraction'>0/57</span>
      </div>
    </div>
  </div>
  <div class='status-line low'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202</td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">/* eslint camelcase: 0 */
<span class="cstat-no" title="statement not covered" >import React, { PropTypes } from 'react';</span>
<span class="cstat-no" title="statement not covered" >import { bindActionCreators } from 'redux';</span>
<span class="cstat-no" title="statement not covered" >import * as actions from '../actions/exploreActions';</span>
<span class="cstat-no" title="statement not covered" >import { connect } from 'react-redux';</span>
<span class="cstat-no" title="statement not covered" >import ChartContainer from './ChartContainer';</span>
<span class="cstat-no" title="statement not covered" >import ControlPanelsContainer from './ControlPanelsContainer';</span>
<span class="cstat-no" title="statement not covered" >import SaveModal from './SaveModal';</span>
<span class="cstat-no" title="statement not covered" >import QueryAndSaveBtns from './QueryAndSaveBtns';</span>
<span class="cstat-no" title="statement not covered" >import { getExploreUrl } from '../exploreUtils';</span>
<span class="cstat-no" title="statement not covered" >import { getFormDataFromControls } from '../stores/store';</span>
&nbsp;
c</span>onst propTypes = <span class="cstat-no" title="statement not covered" >{
  actions: PropTypes.object.isRequired,
  datasource_type: PropTypes.string.isRequired,
  chartStatus: PropTypes.string,
  controls: PropTypes.object.isRequired,
  forcedHeight: PropTypes.string,
  form_data: PropTypes.object.isRequired,
  standalone: PropTypes.bool.isRequired,
  triggerQuery: PropTypes.bool.isRequired,
  queryRequest: PropTypes.object,
};
&nbsp;
class ExploreViewContainer extends React.Component {
<span class="fstat-no" title="function not covered" >  constructor(</span>props) <span class="cstat-no" title="statement not covered" >{</span>
    super(props);
<span class="cstat-no" title="statement not covered" >    this.state = {</span>
      height: this.getHeight(),
      showModal: false,
    };
  }
&nbsp;
  componentDidMount() {
<span class="cstat-no" title="statement not covered" >    this.props.actions.fetchDatasources();</span>
<span class="cstat-no" title="statement not covered" >    window.addEventListener('resize', this.handleResize.bind(this));</span>
  }
&nbsp;
  componentWillReceiveProps(np) {
<span class="cstat-no" title="statement not covered" >    if (np.controls.viz_type.value !== this.props.controls.viz_type.value) {</span>
<span class="cstat-no" title="statement not covered" >      this.props.actions.resetControls();</span>
<span class="cstat-no" title="statement not covered" >      this.props.actions.triggerQuery();</span>
    }
<span class="cstat-no" title="statement not covered" >    if (np.controls.datasource.value !== this.props.controls.datasource.value) {</span>
<span class="cstat-no" title="statement not covered" >      this.props.actions.fetchDatasourceMetadata(np.form_data.datasource, true);</span>
    }
  }
&nbsp;
  componentDidUpdate() {
<span class="cstat-no" title="statement not covered" >    if (this.props.triggerQuery &amp;&amp; !this.hasErrors()) {</span>
<span class="cstat-no" title="statement not covered" >      this.runQuery();</span>
    }
  }
&nbsp;
  componentWillUnmount() {
<span class="cstat-no" title="statement not covered" >    window.removeEventListener('resize', this.handleResize.bind(this));</span>
  }
&nbsp;
  onQuery() {
    // remove alerts when query
<span class="cstat-no" title="statement not covered" >    this.props.actions.removeControlPanelAlert();</span>
<span class="cstat-no" title="statement not covered" >    this.props.actions.removeChartAlert();</span>
&nbsp;
<span class="cstat-no" title="statement not covered" >    this.runQuery();</span>
<span class="cstat-no" title="statement not covered" >    history.pushState(</span>
      {},
      document.title,
      getExploreUrl(this.props.form_data));
  }
&nbsp;
  onStop() {
<span class="cstat-no" title="statement not covered" >    this.props.actions.chartUpdateStopped(this.props.queryRequest);</span>
  }
&nbsp;
  getHeight() {
<span class="cstat-no" title="statement not covered" >    if (this.props.forcedHeight) {</span>
<span class="cstat-no" title="statement not covered" >      return this.props.forcedHeight + 'px';</span>
    }
    c</span>onst navHeight = <span class="cstat-no" title="statement not covered" >this.props.standalone ? 0 : 90;
<span class="cstat-no" title="statement not covered" >    return `${window.innerHeight - navHeight}px`;</span>
  }
&nbsp;
&nbsp;
  runQuery() {
<span class="cstat-no" title="statement not covered" >    this.props.actions.runQuery(this.props.form_data);</span>
  }
&nbsp;
  handleResize() <span class="cstat-no" title="statement not covered" >{</span>
<span class="cstat-no" title="statement not covered" >    clearTimeout(this.resizeTimer);</span>
<span class="cstat-no" title="statement not covered" >    this.resizeTimer = setTimeout(<span class="fstat-no" title="function not covered" >() =&gt; </span>{</span>
<span class="cstat-no" title="statement not covered" >      this.setState({ height: this.getHeight() });</span>
    }, 250);
  }
&nbsp;
  toggleModal() {
<span class="cstat-no" title="statement not covered" >    this.setState({ showModal: !this.state.showModal });</span>
  }
  hasErrors() {
    c</span>onst ctrls = <span class="cstat-no" title="statement not covered" >this.props.controls;
<span class="cstat-no" title="statement not covered" >    return Object.keys(ctrls).some(<span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >k =&gt; ctrls[k].validationErrors.length &gt; 0);</span></span></span>
  }
  renderErrorMessage() {
    // Returns an error message as a node if any errors are in the store
    c</span>onst errors = <span class="cstat-no" title="statement not covered" >[];
<span class="cstat-no" title="statement not covered" >    for (const controlName in this.props.controls) {</span>
      c</span>onst control = <span class="cstat-no" title="statement not covered" >this.props.controls[controlName];
<span class="cstat-no" title="statement not covered" >      if (control.validationErrors &amp;&amp; control.validationErrors.length &gt; 0) {</span>
<span class="cstat-no" title="statement not covered" >        errors.push(</span>
          &lt;div key={controlName}&gt;
            &lt;strong&gt;{`[ ${control.label} ] `}&lt;/strong&gt;
            {control.validationErrors.join('. ')}
          &lt;/div&gt;
        );
      }
    }
    l</span>et <span class="cstat-no" title="statement not covered" >errorMessage;
<span class="cstat-no" title="statement not covered" >    if (errors.length &gt; 0) {</span>
<span class="cstat-no" title="statement not covered" >      errorMessage = (</span>
        &lt;div style={{ textAlign: 'left' }}&gt;{errors}&lt;/div&gt;
      );
    }
<span class="cstat-no" title="statement not covered" >    return errorMessage;</span>
  }
  renderChartContainer() {
<span class="cstat-no" title="statement not covered" >    return (</span>
      &lt;ChartContainer
        actions={this.props.actions}
        height={this.state.height}
      /&gt;);
  }
&nbsp;
  render() {
<span class="cstat-no" title="statement not covered" >    if (this.props.standalone) {</span>
<span class="cstat-no" title="statement not covered" >      return this.renderChartContainer();</span>
    }
<span class="cstat-no" title="statement not covered" >    return (</span>
      &lt;div
        id="explore-container"
        className="container-fluid"
        style={{
          height: this.state.height,
          overflow: 'hidden',
        }}
      &gt;
      {this.state.showModal &amp;&amp;
        &lt;SaveModal
          onHide={this.toggleModal.bind(this)}
          actions={this.props.actions}
          form_data={this.props.form_data}
        /&gt;
      }
        &lt;div className="row"&gt;
          &lt;div className="col-sm-4"&gt;
            &lt;QueryAndSaveBtns
              canAdd="True"
              onQuery={this.onQuery.bind(this)}
              onSave={this.toggleModal.bind(this)}
              onStop={this.onStop.bind(this)}
              loading={this.props.chartStatus === 'loading'}
              errorMessage={this.renderErrorMessage()}
            /&gt;
            &lt;br /&gt;
            &lt;ControlPanelsContainer
              actions={this.props.actions}
              form_data={this.props.form_data}
              datasource_type={this.props.datasource_type}
            /&gt;
          &lt;/div&gt;
          &lt;div className="col-sm-8"&gt;
            {this.renderChartContainer()}
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    );
  }
}
&nbsp;
<span class="cstat-no" title="statement not covered" >ExploreViewContainer.propTypes = propTypes;</span>
&nbsp;
f</span>unction <span class="fstat-no" title="function not covered" >mapStateToProps(state) {
  c</span>onst form_data = <span class="cstat-no" title="statement not covered" >getFormDataFromControls(state.controls);
<span class="cstat-no" title="statement not covered" >  return {</span>
    chartStatus: state.chartStatus,
    datasource_type: state.datasource_type,
    controls: state.controls,
    form_data,
    standalone: state.standalone,
    triggerQuery: state.triggerQuery,
    forcedHeight: state.forced_height,
    queryRequest: state.queryRequest,
  };
}
&nbsp;
f</span>unction <span class="fstat-no" title="function not covered" >mapDispatchToProps(dispatch) {
<span class="cstat-no" title="statement not covered" >  return {</span>
    actions: bindActionCreators(actions, dispatch),
  };
}
&nbsp;
export { ExploreViewContainer };
export default connect(mapStateToProps, mapDispatchToProps)(ExploreViewContainer);
&nbsp;</pre></td></tr>
</table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
  Code coverage
  generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Apr 11 2017 20:15:55 GMT-0700 (PDT)
</div>
</div>
<script src="../../../prettify.js"></script>
<script>
window.onload = function () {
        if (typeof prettyPrint === 'function') {
            prettyPrint();
        }
};
</script>
<script src="../../../sorter.js"></script>
</body>
</html>
